package com.example.xuecheng.contentservice.controller;

import com.example.xuecheng.contentservice.service.impl.CourseTeacherServiceImpl;
import dto.SaveCourseTeacherDto;
import exception.ValidationGroups;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import po.CourseTeacher;

import javax.annotation.Resource;
import java.util.List;

/**
 *   课程老师管理接口
 * @author xiehaidong
 */
@Api(description = "课程老师管理接口")
@RestController
@RequestMapping("/courseTeacher")
public class CourseTeacherController {
    @Resource
    private CourseTeacherServiceImpl courseTeacherService;
    @PostMapping("/")
    @ApiOperation("新增/修改课程计划接口")
    public void  createTeacher(@RequestBody @Validated({ValidationGroups.insert.class}) SaveCourseTeacherDto saveCourseTeacherDto){
        courseTeacherService.saveCourseTeacherDto(saveCourseTeacherDto);
    }

    @GetMapping("/list/{courseId}")
    @ApiOperation("查询课程教师")
    public List<CourseTeacher> getCourseTeacher(@PathVariable(value = "courseId") Long courseId){
        return courseTeacherService.getCourseTeacher(courseId);
    }
    @DeleteMapping("/{courseId}/{id}")
    @ApiOperation("删除教师")
    public void deleteTeacher(@PathVariable(value = "courseId") Long courseId,@PathVariable(value = "id")Long id){
        courseTeacherService.deleteTeacher(courseId,id);

    }

}
